<?php

use yii\helpers\Url;

/* @var $this \yii\web\View */
/* @var $content string */
/* @var \common\models\Check $model */

$this->title = '购买申请'
?>
<style>
    .app-order .app-order-item .app-order-item-infos a{
        height: 0.85rem;
        line-height: 0.85rem;
        font-size: 0.6rem;
        color: #fff;
        padding: 0 0.5rem;
        border-radius: 0.425rem;
    }
</style>
<section class="app-container app-order app-order-detail">
    
    <div class="app-order-item" style="height: 6rem;">
        <div class="app-order-item-infos">
            <h3>购买申请</h3>
            <p> 申请时间： <?= date('Y-m-d H:i:s', $model->created_at) ?></p>
            <p> 审核时间： <?= $model->check_time ? date('Y-m-d H:i:s', $model->check_time) : '暂无信息'?></p>
            <p> 审核状态： <?= $model->generateStatus() ?></p>
            <?php
            if($model->type == 2){
                ?>
                <p> 备注信息： <?= $model->remark ?></p>
                <?php
            }
            ?>
            <div class="clearfix">
                <?php
                if( $model->times == 3 ){
                    ?>
                    <a href="<?= Url::toRoute(['site/signup']) ?>" class="pull-right app-status-success">立即购买</a>
                    <?php
                }
                ?>
            </div>
        </div>
    </div>

    <div class="app-order-content">
        <!-- 这里放图片，2张一排 -->
        <ul>
            <?php
            foreach($model->files as $k => $file){
                ?>
                <li class="images"><img src="<?= $file->file_path ?>" alt=""></li>
                <?php
            }
            ?>
        </ul>
    </div>

</section>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    <?php
        if( Yii::$app->wechat->isWechat ){
    ?>
    wx.config(<?= $wxConfig ?>);
    wx.ready(function (){
        document.querySelector('.images').onclick = function (){
            var url = "<?= Yii::$app->request->getHostInfo() ?>";
            var img = this.firstChild.getAttribute('src');
            wx.previewImage({
                current:  url + img,
                urls: [
                    <?php
                    $files = '';
                    foreach( $model->files as $k => $file ){
                        $files .= '"'. Yii::$app->request->getHostInfo() . $file->file_path . '",';
                    }
                    echo $files;
                    ?>
                ]
            });
        };
    });
    <?php
    }
    ?>
</script>
